goog.provide('czk.ui.Button');

goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.ui.Button');

goog.require('czk.ui.ZKComponent');

/**
 * @constructor
 * @extends {czk.ui.ZKComponent}
 */
czk.ui.Button = function() {
  goog.base(this);
};
goog.inherits(czk.ui.Button, czk.ui.ZKComponent);

czk.ui.Button.prototype.btn = null;

czk.ui.Button.prototype.createDom = function() {
  var dh = this.getDomHelper();
  var el = dh.createDom(goog.dom.TagName.DIV, {
    'className': 'inf_btn inf_btn_' + this.className
  });

  var el1 = dh.createDom(goog.dom.TagName.DIV, {
    'className': 'btn_left'
  });
  goog.dom.insertChildAt(el, el1);

  var el2 = dh.createDom(goog.dom.TagName.DIV, {
    'className': 'btn_right'
  });
  goog.dom.insertChildAt(el1, el2);

  this.btn = dh.createDom(goog.dom.TagName.INPUT, {
    'type': 'submit',
    'name': this.name,
    'value': this.label,
    'className': this.className,
    'onclick': function() {
      return false;
    }
  });

  goog.dom.insertChildAt(el2, this.btn);

  this.setElementInternal(el);

};
/** @inheritDoc */
czk.ui.Button.prototype.enterDocument =
    function() {
      goog.base(this, 'enterDocument');
      this.getHandler().listen(this.btn, goog.events.EventType.CLICK,
          this.action, false, this);

    };

czk.ui.Button.prototype.handleZKResponseCommand = function(command) {
  goog.base(this, 'handleZKResponseCommand', command);
  this.getElement()['className'] = this.className;
};

czk.ui.Button.prototype.action = function() {
  this.portlet.sendXhr(this, 'onClick');

};

czk.ui.Button.create = function() {
  return new czk.ui.Button();
};
